<!-- 盖章单位列表弹框 -->
<template>
  <div class="stampUnit">
    <MyTable
      id="sealCompanyId"
      ref="stampUnitRef"
      class="myTableClass"
      :is-mar-class="true"
      :table-data="dialogStampUnitData"
      :columns="dialogStampUnitLabel"
      :table-operation="dialogStampUnitOperation"
      @propClick="btnClick"
    >
      <template #headerLeft>
        <div class="signSeal">
          <el-input v-model="stampUnitName" class="pms-zr-input" placeholder="请输入盖章单位名称" style="width: 180px" clearable />
          <el-input
            v-model="stampUnitCode"
            placeholder="请输入盖章单位编码"
            class="pms-zr-input"
            style="width: 180px;margin-left: 20px;"
            clearable
          />
        </div>
      </template>
    </MyTable>
    <pagination
      v-if="pageParam.total > 10"
      :is-popper-body="false"
      :total="pageParam.total"
      :page.sync="pageParam.pageNum"
      :limit.sync="pageParam.pageSize"
      @pagination="doSearch"
    />
  </div>
</template>

<script>
import MyTable from '@/components/basic/myTable'
import SysConst from '@/common/const'
import {
    dialogStampUnitLabel,
    dialogStampUnitOperation
} from '.'
import {
    queryProviderInfoApi
} from '@/api/attachmentInfo'

export default {
    name: 'StampUnit',
    components: {
        MyTable
    },
    props: {
        prjId: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            dialogStampUnitData: [], // 盖章人数据
            dialogStampUnitLabel, // 盖章人表头
            dialogStampUnitOperation, // 盖章人按钮
            stampUnitName: '', // 盖章单位名称
            stampUnitCode: '', // 盖章单位编码
            // 分页信息
            pageParam: {
                pageSize: SysConst.PAGESIZE, // 每页显示val条
                pageNum: SysConst.CURRENT_PAGE, // 当前页
                total: SysConst.TOTAL // 总数
            }
        }
    },
    created() {
        this.doSearch()
    },
    methods: {
        // 查看数据
        doSearch(item) {
            console.log(item, 'fenye')
            const params = {
                pageNum: item?.page || SysConst.CURRENT_PAGE,
                pageSize: item?.limit || SysConst.PAGESIZE,
                orgName: this.stampUnitName, // 盖章单位名称
                orgCode: this.stampUnitCode, // 盖章单位编码
                prjId: this.prjId
            }
            queryProviderInfoApi(params).then(res => {
                if (+res.code !== 200){
                    return Promise.reject(res)
                }
                console.log(res, 'gaizhangdan')
                this.dialogStampUnitData = res.data.records
                this.pageParam.total = res.data?.total || 0
                this.pageParam.pageSize = item?.limit || SysConst.PAGESIZE
                this.pageParam.pageNum = item?.page || SysConst.CURRENT_PAGE
            })
        },
        // 获取所选数据
        getSelectionStampUnit() {
            const data = this.$refs.stampUnitRef.multipleSelection
            return data
        },
        // 签署人弹框
        btnClick(fun, row) {
            this[fun](row)
        },
        // 查询
        inquire(row) {
            this.doSearch()
        }
    }
}
</script>

<style lang="scss" scoped>
.myTableClass {
    margin-top: 30px;
}

.signSeal {
    display: flex;
    justify-content: flex-start;
    margin-left: 20px;
}
</style>
